import Opt from '@/components/dt/info/Opt.js'
import toolMgr from '@/biz/base/tool.js'

class HeaderOpt extends Opt {

  constructor(info) {
    super(info)
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {

    let files = []
    if (this.info.accessoryBOList) {
      files = this.info.accessoryBOList.map(item => {
        return {
          value: item.accessoryName,
          key: item.accessoryUrl
        }
      })
    }

    this.all = [{
        title: '发放月份',
        key: 'allowanceMonth',
        text: {},
      }, {
        title: '津贴类型',
        key: 'allowanceTypeStr',
        text: {},
      }, {
        title: '项目津贴总额',
        key: 'allowanceMoney',
        text: {
          type: 'number',
          unit: '元'
        },
      }, {
        title: 'OA文电编号',
        key: 'oaNumber',
        text: {},
      }, {
        title: '附件',
        key: 'accessoryBOList',
        col: 24,
        tag: {
          type: 'text',
          closable: false,
          options: files,
          color: 'blue',
          click: (tag) => {
            toolMgr.downloadFile(tag.key, tag.value)
          }
        }
      }, {
        title: '备注',
        col: 24,
        key: 'remark',
        text: {}
      }
    ]
  }
}

export default HeaderOpt
